/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2022-04-08
 * Time: 13:03
 */
class Student {
    int count = 0;
    synchronized public void increase() {
       count++;
    }
}
public class Test01 {
    public static void main(String[] args) {
            Student student = new Student();

            Thread t1 = new Thread() {
                @Override
                public void run() {
                    for (int i = 0; i < 50000; i++) {
                        student.increase();
                    }

                }
            };
        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 50000; i++) {
                    student.increase();
                }
            }
        });
        t1.start();
        t2.start();
        try {
            t1.join();
            t2.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(student.count);
    }
}
